#pragma once
#include <iostream>

namespace lw
{
	template<class Iterator, class Ref, class Ptr>
	struct __reverse_iterator
	{
		typedef __reverse_iterator<Iterator, Ref, Ptr> Self;
		Iterator _it;
		__reverse_iterator(Iterator it)
			:_it(it)
		{}
		
		Self& operator++()
		{
			--_it;
			return *this;
		}
		Self operator++(int)
		{
			Self tmp(*this);
			--_it;
			return tmp;
		}
		Self& operator--()
		{
			++_it;
			return *this;
		}
		Self operator--(int)
		{
			Self tmp(*this);
			++_it;
			return tmp;
		}
		bool operator==(const Self& s) const
		{
			return _it == s._it;
		}
		bool operator!=(const Self& s) const
		{
			return _it != s._it;
		}
		Ref operator*()
		{
			Iterator it = _it;
			--it;
			return *it;
		}
		Ptr operator->()
		{
			Iterator it = _it;
			--it;
			return &it;
		}
	};
}